import request from '@/utils/request'
import qs from 'qs'

export function selectPages(data) {
  return request({
    url: 'api/appDef/selectPages' + '?' + qs.stringify(data, { indices: false }),
    method: 'get'
  })
}

export function del(ids) {
  return request({
    url: 'api/appDef/del',
    method: 'post',
    data: ids
  })
}

export function qryGroupCode() {
  return request({
    url: 'api/appGroup/qryGroupCode',
    method: 'get'
  })
}

export function qryNodeInfo(appCode) {
  return request({
    url: 'api/agentDef/qryNodeInfo?appCode=' + appCode,
    method: 'get'
  })
}

export function findUserByRole(roleId) {
  return request({
    url: 'api/users/findUserByRole?roleId=' + roleId,
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: 'api/appDef/add',
    method: 'post',
    data
  })
}

export function editAppSatus(appSatus, appCode) {
  return request({
    url: 'api/appDef/editAppSatus?appSatus=' + appSatus + '&appCode=' + appCode,
    method: 'post'
  })
}

export function edit(data) {
  return request({
    url: 'api/appDef/edit',
    method: 'post',
    data
  })
}

export function updateAppConf(data) {
  return request({
    url: 'api/appDef/updateAppConf',
    method: 'post',
    data
  })
}

export function getEdit(pkId) {
  return request({
    url: 'api/appDef/getEdit?pkId=' + pkId,
    method: 'get'
  })
}

export function checkAppData(data) {
  return request({
    url: 'api/appDef/checkAppData',
    method: 'post',
    data
  })
}

export function findAppConfDtoByAppCode() {
  return request({
    url: 'api/appDef/findAppConfDtoByAppCode',
    method: 'get'
  })
}

export function qryAppSessionInfo(appCode) {
  return request({
    url: 'api/appDef/qryAppSessionInfo/' + appCode,
    method: 'get'
  })
}

export default { selectPages, del, qryGroupCode, qryNodeInfo, findUserByRole, add, editAppSatus, edit, checkAppData,
  getEdit, findAppConfDtoByAppCode, updateAppConf, qryAppSessionInfo }
